<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="box"></div>
</body>
</html>


<script>
    // function data(obj) {
    //     var str = '';
    //     for (var key in obj) {
    //         str += `${key}=${obj[key]}&`
    //     }
    //     return str.slice(0, str.length - 1);

    // }
    
        var xhr = new XMLHttpRequest();

        xhr.open('get','./news.json')

        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4) {
                let obj= JSON.parse(xhr.responseText)
                var str = obj.list.map((item, index) => {
                        return `<span> ${item.age}</span>  <span> ${item.content} </span> <br>`
                    }).join('')
                    
                    
                };
                document.querySelector('.box').innerHTML = str;
            }
        


        xhr.send();



    
   
    
</script>